/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rbh.risk.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 *
 * @author IT-Mafia
 */
@Entity
@Table(name = "rbh_risk_main_event")
@XmlRootElement
public class MainEvent implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "MAIN_EVENT_ID", unique = true, nullable = false, columnDefinition = "smallint UNSIGNED")
    private Short mainEventId;
    @Column(name = "MAIN_EVENT_DESCRIPTION", length = 1024)
    private String mainEventDescription;
    @Basic(optional = false)
    @Column(name = "MAIN_EVENT_NAME", nullable = false, length = 100)
    private String mainEventName;
    @Basic(optional = false)
    @Column(name = "MAIN_EVENT_ORDER_NUMBER", columnDefinition = "tinyint UNSIGNED default 0", nullable = false)
    private short mainEventOrderNumber;
    @Basic(optional = false)
    @Column(name = "MAIN_EVENT_STATUS", columnDefinition = "boolean default true", nullable = false)
    private boolean mainEventStatus;
    @OneToMany(mappedBy = "mainEvent", fetch = FetchType.LAZY)
    @Cascade({CascadeType.DETACH})
    private List<SubEvent> subEventList;
    @OneToMany(mappedBy = "mainEvent", fetch = FetchType.LAZY)
    @Cascade({CascadeType.DETACH})
    private List<RiskData> riskDataList;
    @JoinColumn(name = "RBH_RISK_CATEGORY", referencedColumnName = "CATEGORY_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private Category category;

    public MainEvent() {
    }

    public MainEvent(Short mainEventId) {
        this.mainEventId = mainEventId;
    }

    public MainEvent(Short mainEventId, String mainEventName, short mainEventOrderNumber, boolean mainEventStatus) {
        this.mainEventId = mainEventId;
        this.mainEventName = mainEventName;
        this.mainEventOrderNumber = mainEventOrderNumber;
        this.mainEventStatus = mainEventStatus;
    }

    public Short getMainEventId() {
        return mainEventId;
    }

    public void setMainEventId(Short mainEventId) {
        this.mainEventId = mainEventId;
    }

    public String getMainEventDescription() {
        return mainEventDescription;
    }

    public void setMainEventDescription(String mainEventDescription) {
        this.mainEventDescription = mainEventDescription;
    }

    public String getMainEventName() {
        return mainEventName;
    }

    public void setMainEventName(String mainEventName) {
        this.mainEventName = mainEventName;
    }

    public short getMainEventOrderNumber() {
        return mainEventOrderNumber;
    }

    public void setMainEventOrderNumber(short mainEventOrderNumber) {
        this.mainEventOrderNumber = mainEventOrderNumber;
    }

    public boolean getMainEventStatus() {
        return mainEventStatus;
    }

    public void setMainEventStatus(boolean mainEventStatus) {
        this.mainEventStatus = mainEventStatus;
    }

    @XmlTransient
    public List<SubEvent> getSubEventList() {
        return subEventList;
    }

    public void setSubEventList(List<SubEvent> subEventList) {
        this.subEventList = subEventList;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @XmlTransient
    public List<RiskData> getRiskDataList() {
        return riskDataList;
    }

    public void setRiskDataList(List<RiskData> riskDataList) {
        this.riskDataList = riskDataList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mainEventId != null ? mainEventId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MainEvent)) {
            return false;
        }
        MainEvent other = (MainEvent) object;
        if ((this.mainEventId == null && other.mainEventId != null) || (this.mainEventId != null && !this.mainEventId.equals(other.mainEventId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.rbh.risk.entity.MainEvent[ mainEventId=" + mainEventId + " ]";
    }
}
